package utils

import (
	"crypto/md5"
	"encoding/hex"
)

// HashPassword 密码加密
func HashPassword(password string) string {
	h := md5.New()
	h.Write([]byte(password))
	return hex.EncodeToString(h.Sum(nil))
}

// ComparePassword 比较密码
func ComparePassword(hashedPassword, password string) bool {
	hashedInput := HashPassword(password)
	return hashedPassword == hashedInput
}
